var webpack = require("webpack");
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var extractCss = new ExtractTextPlugin('css/index.css');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var path = require('path');


module.exports = {
	entry : {
		app:__dirname+"/src/js/index.js",
		more:[ __dirname+"/src/js/a.js",__dirname+"/src/js/b.js",__dirname+"/src/js/c.js"],
		v:['jquery']
	},
	output : {
		path:__dirname+"/assets/",
		filename:"js/[name].js",
		publicPath:"http://192.168.2.42:3333/assets"
	},
	devServer:{
		contentBase:"./",
		host:"192.168.2.42",
		port:"3333"
	},
	module:{
		loaders:[
			// {
			// 	test:/\.css$/,
			// 	loader:'style-loader!css-loader'
			// },
			{
				test:/\.css$/,
				loader:extractCss.extract({ fallback: 'style-loader', use: 'css-loader' })
			},
			{
				test:/\.less$/,
				loader:'style!css!less'
			},
			{
				test:/\.json$/,
				loader:'json-loader'
			},
			{
		        test: /\.js$/,
		        exclude: /node_modules/,
		        loader: 'babel-loader',
		        query:{
		        	presets:['es2015','react']
		        }
		    },
		    {
		    	test:/\.png$/,
		    	loader:"file-loader?limit=50000&name=/images/[hash:8].[name].[ext]"
		    }
		]
	},
	plugins:[
		new webpack.HotModuleReplacementPlugin(),
		extractCss,
		new HtmlWebpackPlugin({
			title:'wangruiyu-wangruiyu',
			filename:'../index.html',
			template:__dirname+'/src/tpl/index.html',
			inject:'body',
			info:'Hello World'
		}),
		new webpack.optimize.UglifyJsPlugin({
		    compress: {
		        warnings: false
		    }
		}),
		new webpack.ProvidePlugin({
			$:'jquery'
		}),
		// new webpack.optimize.CommonsChunkPlugin({
		// 	name: 'v',
		//     filename: 'lib/jquery.min.js'
		// })
		new webpack.optimize.CommonsChunkPlugin({
			names: ["a","b","c"]
		})
	],
	// externals:{
	// 	jquery:'http://libs.baidu.com/jquery/2.1.1/jquery.min.js'//百度jq cdn
	// }
	watch:true,


	// resolve:{
	// 	root: [
	// 	    path.resolve('d:/js/')
	// 	],
	// 	// root:'d:/js/',
	// 	extensions:['','.js'],
	// 	alias:{
	// 		appAdd:'add.js'
	// 	}
	// }
}